<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <link rel="stylesheet" href="/Public/Admin/css/style.css"/>
    <style>
        .layui-form .layui-form-item label.layui-form-label{width:150px}
        .layui-input, .layui-textarea{width:90%}
        #upload{background:url(/Public/Admin/images/file.png) no-repeat left center;padding-left:20px;padding-bottom:20px;display: inline-block;height: 38px;line-height: 38px;}
        .layui-form-item .title{font-size: 14px;font-weight: bold;border-bottom: 2px solid #2299ee;display: block;padding-bottom: 6px}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Flow/flowStep',array('flow_id'=>$flow_id))}">返回</a>
                    </div>
                </blockquote>

                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="inputArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$info.prcs_name|default="新步骤"} - 基本设置 <img class="pointer arrow" src="/Public/Admin/images/down.png" /></span>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>步骤号</label>
                            <div class="layui-input-block">
                                <input type="text" name="prcs_id" class="layui-input" value="{$info.prcs_id}">
                                <span class="errMsg"></span>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>步骤名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="prcs_name" class="layui-input" value="{$info.prcs_name}">
                                <span class="errMsg"></span>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">下一步骤</label>
                            <div class="layui-input-block">
                                <div class="left">
                                    <p class="head">下一步骤</p>
                                    <ul>
                                        <if condition="$info['nextSteps'] neq null">
                                            <foreach name="info.nextSteps" item="next">
                                                <li class="add-step pointer" data-step="{$next}"><if condition="$next neq 'end'">{$next}. </if>{$next|getFlowProcessName=$info['flow_id'],###}<input type="hidden" name="prcs_to[]" value="{$next}"></li>
                                            </foreach>
                                        </if>
                                    </ul>
                                </div>
                                <div class="center">
                                    <img src="/Public/Admin/images/a-right.png" class="a-right pointer"/>
                                    <img src="/Public/Admin/images/a-left.png" class="a-left pointer"/>
                                </div>
                                <div class="right">
                                    <p class="head">备选步骤</p>
                                    <ul>
                                        <foreach name="steps" item="step">
                                            <li class="flow-step pointer" data-step="{$step.prcs_id}">{$step.prcs_id}. {$step.prcs_name}<input type="hidden" name="prcs_to[]" value=""></li>
                                        </foreach>
                                        <if condition="$is_end eq 0">
                                            <li class="flow-step pointer" data-step="end">[结束]<input type="hidden" name="prcs_to[]" value=""></li>
                                        </if>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="tableArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$info.prcs_name|default="新步骤"} - 选人规则 <img class="pointer arrow" src="/Public/Admin/images/up.png" /></span>
                        </div>
                        <div style="display: none" id="select-role">
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="c-red">*</span>自动过滤规则</label>
                                <div class="layui-input-block">
                                    <select name="user_filter" class="layui-input" lay-verify="required">
                                        <option value="" {$info['user_filter'] == '' ? 'selected' : ''}>允许选择全部指定的经办人</option>
                                        <option value="1" {$info['user_filter'] == 1 ? 'selected' : ''}>只允许选择本部门经办人</option>
                                        <option value="2" {$info['user_filter'] == 2 ? 'selected' : ''}>只允许选择本角色经办人</option>
                                        <option value="6" {$info['user_filter'] == 6 ? 'selected' : ''}>只允许选择指定部门经办人</option>
                                        <option value="7" {$info['user_filter'] == 7 ? 'selected' : ''}>只允许选择指定角色经办人</option>
                                    </select>
                                </div>
                                <p class="red">说明:选人过滤规则在流程转交选择经办人时生效，默认设置为允许选择全部指定的经办</p>
                            </div>
                            <div class="layui-form-item" style="margin-bottom: 0">
                                <label class="layui-form-label"><span class="c-red">*</span>自动选人规则</label>
                                <div class="layui-input-block">
                                    <select name="auto_type" class="layui-input" lay-verify="required">
                                        <option value="" {$info['auto_type'] == '' ? 'selected' : ''}>不进行自动选择</option>
                                        <option value="1" {$info['auto_type'] == 1 ? 'selected' : ''}>自动选择流程发起人</option>
                                        <option value="2" {$info['auto_type'] == 2 ? 'selected' : ''}>自动选择本部门负责人</option>
                                        <option value="6" {$info['auto_type'] == 6 ? 'selected' : ''}>自动选择上级领导</option>
                                        <option value="8" {$info['auto_type'] == 8 ? 'selected' : ''}>自动选择指定步骤主办人</option>
                                        <option value="3" {$info['auto_type'] == 3 ? 'selected' : ''}>指定自动选择默认人员</option>
                                        <option value="9" {$info['auto_type'] == 9 ? 'selected' : ''}>指定自动选择默认角色</option>
                                    </select>
                                </div>
                            </div>
                            <!--选项3时展开-->
                            <div id="auto_user" style="display:none">
                                <div class="layui-form-item" style="margin-top: 15px">
                                    <label class="layui-form-label">主办人</label>
                                    <div class="layui-input-block">
                                        <p class="auto_user_op">
                                        <if condition="$info['auto_user_op'] neq null">
                                            <span class="one-name">
                                                <a>{$info.auto_user_op|getChineseName}</a><img class="pointer delOperator" data-id="{$info.auto_user_op}" src="/Public/Index/img/close_red.png" width="12">
                                                <input type="hidden" name="user_id" value="{$info.auto_user_op}">
                                                <input type="hidden" name="user_name" value="{$info.auto_user_op|getChineseName}">
                                            </span>
                                        </if>
                                        </p>
                                        <span class="red" style="margin-left:0"><b>主办人是某步骤的负责人，只允许主办人编辑表单、公共附件和转交流程</b></span>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">经办人</label>
                                    <div class="layui-input-block value">
                                        <div class="auto_user textarea">
                                            <span></span>
                                            <if condition="$info['users'] neq null">
                                                <foreach name="info.users" item="user">
                                                    <span class="one-name">
                                                        <a>{$user|getChineseName}</a><img class="pointer delOperator" data-id="{$user}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                                        <input type="hidden" name="user_ids[]" value="{$user}">
                                                        <input type="hidden" name="user_names[]" value="{$user|getChineseName}">
                                                    </span>
                                                </foreach>
                                            </if>
                                        </div>
                                        <a class="pointer flowCheckUser" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/add.png"/> 指定主办/经办人&nbsp;&nbsp;</a>
                                        <a class="pointer clearData" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/del1.png"/> 清空</a>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <p class="red">说明:通过自动选人规则，是流程经办人通过指定的规则智能选择。默认设置为:不能自动选择。注意，请同时设置好经办权限，自动选择规则才能生效</p>
                                </div>
                            </div>
                            <!--选项16时展开-->
                            <div id="auto_priv" style="display:none">
                                <div class="layui-form-item" style="margin-top: 15px">
                                    <label class="layui-form-label">指定角色</label>
                                    <div class="layui-input-block value">
                                        <div class="textarea priv">
                                            <span></span>
                                            <if condition="$info['prives'] neq null">
                                                <foreach name="info.prives" item='prive'>
                                                    <span style="padding-right:10px">
                                                        <a>{$prive|getPrivName}</a><img class="pointer delOperator" data-id="{$prive}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                                        <input type="hidden" name="auto_prive[]" value="{$prive}">
                                                        <input type="hidden" name="priv_name[]" value="{$prive|getPrivName}">
                                                    </span> 
                                                </foreach>
                                            </if>
                                        </div>
                                        <a class="pointer addPriv" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/add.png"/> 添加角色&nbsp;&nbsp;</a>
                                        <a class="pointer clearData" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/del1.png"/> 清空</a>
                                    </div>
                                    <!--定义数据表中的键名-->
                                    <input type="hidden" id="field" value="auto_prive" />
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="tableArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$info.prcs_name|default="新步骤"} - 流转设置 <img class="pointer arrow" src="/Public/Admin/images/up.png" /></span>
                        </div>
                        <div style="display: none" id="other-set">
                            <div class="layui-form-item">
                                <label class="layui-form-label">主办人相关选项</label>
                                <div class="layui-input-block">
                                    <lable class="input_lable">
                                        <input name="top_default" type="radio" value="0" {$info['top_default'] == 0 ? 'checked' :''} />明确指定主办人

                                    </lable>
                                    <lable class="input_lable">
                                        <input type="radio" value="2" name="top_default" {$info['top_default'] == 2 ? 'checked' :''} />无主办人会签
                                    </lable>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">是否允许会签</label>
                                <div class="layui-input-block">
                                    <lable class="input_lable">
                                        <input name="feedback" type="radio" value="0" {$info['feedback'] == 0 ? 'checked' :''} />允许会签

                                    </lable>
                                    <lable class="input_lable">
                                        <input type="radio" value="1" name="feedback" {$info['feedback'] == 1 ? 'checked' :''} />禁止会签
                                    </lable>
                                    <lable class="input_lable">
                                        <input type="radio" value="2" name="feedback" {$info['feedback'] == 2 ? 'checked' :''} />强制会签
                                    </lable>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">是否允许退回</label>
                                <div class="layui-input-block">
                                    <lable class="input_lable">
                                        <input name="allow_back" type="radio" value="0" {$info['allow_back'] == 0 ? 'checked' :''} />不允许退回
                                    </lable>
                                    <lable class="input_lable">
                                        <input type="radio" value="2" name="allow_back" {$info['allow_back'] == 2 ? 'checked' :''} />允许退回之前步骤
                                    </lable>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('newFlowStep')}" data-form="">提交</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                    <input type="hidden" name="flow_id" value="{$flow_id}">
                    <input type="hidden" id="one" value="1">
                </form>
                <!-- 完 -->
            </div>
        </div>
        <input type="hidden" name="prcs_id" value="{$prcs_id|default=0}">
    </section>
</block>
<block name="script">

    <script type="text/javascript" src="/Public/Admin/js/flow.js"></script>
    <script type="text/javascript">
        $(initFlowStep());

        $(function () {
            $('input[name=prcs_id]').focus();
        })

        //检查表单
        var flag = true;
        $('input[name=prcs_id]').on('blur', function () {
            var num = parseInt($(this).val());
            if (isNaN(num) || $(this).val() == '') {
                var msg = '步骤号必填且为整数！'
                $(this).next().text(msg);
                $('.ajax-post').removeClass('btn-submit');
            } else {
                $(this).next().text('');
                $('.ajax-post').addClass('btn-submit');
            }
        })

        $('input[name="prcs_name"]').on('blur', function () {
            if ($('input[name="prcs_name"]').val() == '') {
                var msg = '请填写步骤名称！'
                $('input[name="prcs_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
        })

        $('.ajax-post').on('click', function () {
            var flag = true;
            if ($('input[name="prcs_name"]').val() == '') {
                var msg = '请填写步骤名称！'
                $('input[name="prcs_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }

            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })


    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
</block>
